package com.huifaapp.mall.adapter.adapter2;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.huifaapp.mall.R;
import com.huifaapp.mall.bean.Huishengqian.LivingmoneyLog;
import com.jcodecraeer.xrecyclerview.XRecyclerView;

import java.util.ArrayList;
import java.util.List;

/**
 * @desc
 * @auth Mr Wu Fan
 * Created by you on 2018/3/19.
 */

public class Shengqianxrecycleviewadpter extends XRecyclerView.Adapter<Shengqianxrecycleviewadpter.Viewhoder> {
    private  List<LivingmoneyLog.DataBean> data = new ArrayList<>();
    private Context context;

    public Shengqianxrecycleviewadpter(List<LivingmoneyLog.DataBean> data, Context context) {
        this.data = data;
        this.context = context;
    }

    public void setData(List<LivingmoneyLog.DataBean> data){
        this.data = data;
        notifyDataSetChanged();
    }
    public  void setadddata( List<LivingmoneyLog.DataBean> data){

        data.addAll(data);
    }

    @Override
    public Viewhoder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_shengqian, null);
        Viewhoder vh = new Viewhoder(view);
        return vh;
    }

    @Override
    public void onBindViewHolder(Viewhoder holder, int position) {
        holder.tvnum.setText("+"+data.get(position).getMoney());
        holder.tvtime.setText(data.get(position).getCreateTime());
        String type = data.get(position).getType();
        if (type.equals("yh")){
            holder.tvname.setText(data.get(position).getInfo());
        }

    }

    @Override
    public int getItemCount() {
        return data.size();
    }

    class  Viewhoder extends XRecyclerView.ViewHolder{
        TextView tvnum;
        TextView tvname;
        TextView tvtime;

        public Viewhoder(View itemView) {
            super(itemView);
            tvnum = (TextView) itemView.findViewById(R.id.tvnum);
            tvname = (TextView) itemView.findViewById(R.id.tv_shengqian_name);
            tvtime = (TextView) itemView.findViewById(R.id.tvTime);
        }
    }
}
